import os
import sys

import django

# 1. 伪造，让Django启动
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_dir)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "order_platform.settings")
django.setup()

from utils.encrypt import md5
from web import models

# 2. 写入数据
# level_obj = models.Level.objects.create(title='VVIP', percent=80)
level_obj = models.Level.objects.filter(title='VIP', percent=90).first()

for i in range(999):
    models.Customer.objects.create(
        username=f'Job-{i}',
        password=md5(f'Job-{i}'),
        mobile='1898899' + str(i).zfill(4),
        level=level_obj,
        creator_id=2,
    )
